<html>
  <head>
    <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Head First Golang | Elvis Zhang</title>
<meta name="description" content="The easy way or the right way." />
<link rel="shortcut icon" href="https://blog.shunzi.tech/favicon.ico">
<link rel="stylesheet" href="https://blog.shunzi.tech/styles/main.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.10.0/katex.min.css">

<script data-ad-client="ca-pub-7661668224317940" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script src="https://blog.shunzi.tech/media/js/jquery.min.js"></script>
<script src="https://blog.shunzi.tech/media/js/masonry.pkgd.min.js"></script>
<script src="https://blog.shunzi.tech/media/js/aos.js"></script>
<script src="https://blog.shunzi.tech/media/js/pace.min.js"></script>
<script src="https://blog.shunzi.tech/media/js/view-image.min.js"></script>
<script src="https://blog.shunzi.tech/media/js/jquery.magnific-popup.min.js"></script>
<script src="https://blog.shunzi.tech/media/js/functions.js"></script>
    <meta name="referrer" content="never">
    <meta name="description" content="

Head first Golang.
Here is the basic of go-language, including grammer basic and some features.
The content is based o..." />
    <meta name="keywords" content="编程语言" />
    <script src="https://blog.shunzi.tech/media/js/waterfall.min.js"></script>
    <script src="https://blog.shunzi.tech/media/js/prism.min.js"></script>
  </head>
  <body>
            <header id="header" class="grid-container">
        <!-- start: .menu-wrapper -->
        <div class="menu-mobile"> 
          <i class="fa fa-reorder"></i>
        </div>
        <div class="menu-wrapper">
          <div class="">
            <div class="logo">
              <a href="https://blog.shunzi.tech"><img src="\media\images\custom-headerLogo.jpg" alt=""></a>
            </div>
            <!-- start: .main-nav -->

            <nav class="main-nav grid-container grid-parent">
              <ul id="menu-header" class="menu gradient-effect">
                <li class=""><a href="https://blog.shunzi.tech" class="menu">首页</a></li>
                
                  <li class="" >
                    <a href="/archives" class="menu">
                      归档
                    </a>
                  </li>
                
                  <li class="" >
                    <a href="/tag/diary" class="menu">
                      随笔
                    </a>
                  </li>
                
                  <li class="" >
                    <a href="/movies" class="menu">
                      观影
                    </a>
                  </li>
                
                  <li class="" >
                    <a href="/post/about" class="menu">
                      关于
                    </a>
                  </li>
                
                <li class="search-menu-item hide-on-mobile hide-on-tablet"><a href="#search-lightbox" class="lightbox mfp-inline"><i class="fa fa-search-line"></i></a></li>
              </ul>
            </nav>
            <a href="#search-lightbox" class="lightbox epcl-search-button mfp-inline hide-on-tablet hide-on-desktop"><i class="fa fa-search-line"></i></a>
            <!-- end: .main-nav -->
            <div class="clear"></div>
            <div class="border hide-on-tablet hide-on-mobile"></div>
          </div>    
          <div class="clear"></div>
        </div>
        <!-- end: .menu-wrapper -->
        <div class="clear"></div>
      </header>
      <div class="hide-on-mobile hide-on-tablet hide-on-desktop">
        <div id="search-lightbox" class="grid-container grid-small grid-parent mfp-hide">
          <div class="search-wrapper section">
            <form id="gridea-search-form" data-update="1620954331293" action="/search/index.html" class="search-form" _lpchecked="1">
              <input type="text" name="q" id="s" value="" class="search-field" placeholder="搜点啥..." aria-label="搜点啥..." required="">
              <button type="submit" class="submit" aria-label="Submit">
                <i class="fa fa-search-line"></i>
              </button>
            </form>
          </div>
        </div>
      </div>

      <main id="single" class="main grid-container fullcover no-sidebar aos-init aos-animate" data-aos="fade">

        <div class="center content">
          <div class="featured-image cover" style="background-image: url('https://raw.githubusercontent.com/zjs1224522500/PicGoImages/master//img/blog/20200611220832.png');">
            <div class="meta top"> 
              <time class="meta-info" style="float:left;" datetime="2020-06-11"><i class="fa fa-calendar"></i><span class="lately">1 年前</span></time>
              
              <a href="https://blog.shunzi.tech/post/head-first-go-lang/#comments" class="comments meta-info" title="">
                <i class="fa fa-comment remixicon"></i><span class="comment-count valine-comment-count" data-xid="/head-first-go-lang/"> </span>
              </a>
              <span id="/head-first-go-lang/" class="leancloud_visitors views-counter meta-info" title=""><i class="fa fa-leancloud remixicon"></i><span class="leancloud-visitors-count"></span></span>
              
            </div>
            <div class="info">
              <div class="tags ">
                
                      <a href="https://blog.shunzi.tech/tag/n2w6bz87h/" class="ctag ctag-0 ctag-n2w6bz87h" aria-label="">编程语言</a>
                    
              </div>
              <h1 class="title ularge white bold">Head First Golang</h1>
            </div>
          </div>
        </div>  

        <div class="epcl-page-wrapper">
          <div class="left-content grid-70 np-mobile">
            <article class="main-article post">
              <section class="post-content">
                <div class="text">
                  <blockquote>
<ul>
<li>Head first Golang.</li>
<li>Here is the basic of go-language, including grammer basic and some features.</li>
<li>The content is based on the tutorial <a href="https://tour.golang.org/welcome/1">A tour of Go</a> and I will present my understanding.</li>
<li>Furthermore, I will try to anaylyze the priciple</li>
</ul>
</blockquote>
<!-- more -->
<h2 id="basic">Basic</h2>
<ul>
<li><a href="https://tour.golang.org/welcome/1">A tour of Go (Online)</a></li>
</ul>
<h3 id="index-of-a-tour-of-go">Index of A tour of Go</h3>
<h4 id="basic-2">Basic</h4>
<ul>
<li><a href="https://github.com/zjs1224522500/GoLearn/blob/master/hello.go">[1] Hello world</a></li>
</ul>
<pre><code class="language-Go">package main
import &quot;fmt&quot;
func main() {
  fmt.Println(&quot;Hello, Golang World!&quot;)
}
</code></pre>
<ul>
<li><a href="https://github.com/zjs1224522500/GoLearn/blob/master/package/imports.go">[2] Package</a></li>
<li><a href="https://github.com/zjs1224522500/GoLearn/blob/master/function/function.go">[3] Function</a></li>
<li><a href="https://github.com/zjs1224522500/GoLearn/blob/master/variables/variables.go">[4] Variables</a></li>
<li><a href="https://github.com/zjs1224522500/GoLearn/blob/master/basictype/basic-types.go">[5] Basic Type</a></li>
<li><a href="https://github.com/zjs1224522500/GoLearn/blob/master/flow-control/flow-control.go">[6] Flow Control</a>
<ul>
<li><a href="https://tour.golang.org/flowcontrol/8">Exercise: Loops and Functions Description</a></li>
<li><a href="https://tour.golang.org/flowcontrol/8">Exercise: Loops and Functions Solution</a></li>
</ul>
</li>
<li><a href="https://github.com/zjs1224522500/GoLearn/blob/master/struct/struct.go">[7] Poiner, Struct, Slices</a>
<ul>
<li><a href="https://tour.golang.org/moretypes/18">Exercise: Slices Description</a></li>
<li><a href="https://github.com/zjs1224522500/GoLearn/blob/master/SliceExercise/SliceExercise.go">Exercise: Slices Solution</a></li>
</ul>
</li>
<li><a href="https://github.com/zjs1224522500/GoLearn/blob/master/map/map.go">[8] Map</a>
<ul>
<li><a href="https://tour.golang.org/moretypes/23">Exercise: Word Count Description</a></li>
<li><a href="https://github.com/zjs1224522500/GoLearn/blob/master/WordCountEx/map-exercise.go">Exercies: Word Count Solution</a></li>
</ul>
</li>
</ul>
<pre><code class="language-Go">package main
import (
  &quot;strings&quot;
  &quot;golang.org/x/tour/wc&quot;
)

func WordCount(s string) map[string]int {
  m := make(map[string]int)
  words := strings.Fields(s)
  for _, v := range words {
    m[v]++
  }
  return m
}
func main() {
  wc.Test(WordCount)
}
</code></pre>
<ul>
<li><a href="https://github.com/zjs1224522500/GoLearn/blob/master/functionValues/function-value.go">[9] Function As Value</a>
<ul>
<li><a href="https://tour.golang.org/moretypes/26">Exercise: Fibonacci closure Description</a></li>
<li><a href="https://github.com/zjs1224522500/GoLearn/blob/master/Fibonacci/Fibonacci.go">Exercise: Fibonacci closure Solution</a></li>
</ul>
</li>
</ul>
<pre><code class="language-Go">package main
import &quot;fmt&quot;
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
  fib1 := 0
  fib2 := 1
  return func() int {
    fib2 = fib1 + fib2
    fib1 = fib2 - fib1
    return fib2 - fib1
  }
}

func main() {
  f := fibonacci()
  for i := 0; i &lt; 10; i++ {
    fmt.Println(f())
  }
}
</code></pre>
<h4 id="methods-and-interfaces">Methods and Interfaces</h4>
<ul>
<li><a href="https://github.com/zjs1224522500/GoLearn/blob/master/methods/methods.go">[1] Methods</a>
<ul>
<li>注意值传递 还是 引用传递</li>
</ul>
</li>
</ul>
<pre><code class="language-Go">package main

import &quot;fmt&quot;

func main() {
	/* 定义局部变量 */
	var a int = 100
	var b int = 200
	var c int = 100
	var d int = 200

	fmt.Printf(&quot;交换前 a 的值为 : %d\n&quot;, a)
	fmt.Printf(&quot;交换前 b 的值为 : %d\n&quot;, b)

	/* 通过调用函数来交换值 */
	valueSwap(a, b)

	fmt.Printf(&quot;value_swap 交换后 a 的值 : %d\n&quot;, a)
	fmt.Printf(&quot;value_swap 交换后 b 的值 : %d\n&quot;, b)

	fmt.Printf(&quot;交换前 c 的值为 : %d\n&quot;, c)
	fmt.Printf(&quot;交换前 d 的值为 : %d\n&quot;, d)

	refSwap(&amp;c, &amp;d)
	fmt.Printf(&quot;pref_swap 交换后 c 的值为 : %d\n&quot;, c)
	fmt.Printf(&quot;pref_swap 交换后 d 的值为 : %d\n&quot;, d)
}

/* 定义相互交换值的函数 */
func valueSwap(x, y int) int {
	var temp int

	temp = x /* 保存 x 的值 */
	x = y    /* 将 y 值赋给 x */
	y = temp /* 将 temp 值赋给 y*/

	return temp
}

/* 定义交换值函数*/
func refSwap(x *int, y *int) {
	var temp int
	temp = *x /* 保持 x 地址上的值 */
	*x = *y   /* 将 y 值赋给 x */
	*y = temp /* 将 temp 值赋给 y */
}

</code></pre>
<ul>
<li><a href="https://github.com/zjs1224522500/GoLearn/blob/master/interfaces/interface.go">[2] Interfaces</a>
<ul>
<li>根据函数名来确定接口实现关系</li>
</ul>
</li>
</ul>
<pre><code class="language-Go">package main

import &quot;fmt&quot;

type Phone interface {
    call(param int) string
    takephoto()
}

type Huawei struct {
}

func (huawei Huawei) call(param int) string{
    fmt.Println(&quot;i am Huawei, i can call you!&quot;, param)
    return &quot;damon&quot;
}

func (huawei Huawei) takephoto() {
    fmt.Println(&quot;i can take a photo for you&quot;)
}

func main(){
    var phone Phone
    phone = new(Huawei)
    phone.takephoto()
    r := phone.call(50)
    fmt.Println(r)
}
</code></pre>
<ul>
<li><a href="https://github.com/zjs1224522500/GoLearn/blob/master/typeassert/type-assertions.go">[3] Type Assertions</a></li>
</ul>
<pre><code class="language-Go">package main

import &quot;fmt&quot;

// type switches
func do(i interface{}) {
	switch v := i.(type) {
	case int:
		fmt.Printf(&quot;Twice %v is %v\n&quot;, v, v*2)
	case string:
		fmt.Printf(&quot;%q is %v bytes long\n&quot;, v, len(v))
	default:
		fmt.Printf(&quot;I don't know about type %T!\n&quot;, v)
	}
}

func testTypeSwitchs() {
	do(21)
	do(&quot;hello&quot;)
	do(true)
}
W
func testTypeAssert() {
	var i interface{} = &quot;hello&quot;

	// t := i.(T)
	s := i.(string)
	fmt.Println(s)

	// f = i.(float64) // panic
	// fmt.Println(f)

	// t, ok := i.(T)
	s, ok := i.(string)
	fmt.Println(s, ok)

	f, ok := i.(float64)
	fmt.Println(f, ok)
}

func main() {
	testTypeAssert()
	testTypeSwitchs()
}
</code></pre>
<ul>
<li><a href="https://github.com/zjs1224522500/GoLearn/blob/master/stringers/stringers.go">[4] Stringers</a></li>
</ul>
<pre><code class="language-Go">package main

import &quot;fmt&quot;

// Person struct
type Person struct {
	Name string
	Age  int
}

func (p Person) String() string {
	return fmt.Sprintf(&quot;%v (%v years)&quot;, p.Name, p.Age)
}

func testStringers() {
	a := Person{&quot;Arthur Dent&quot;, 42}
	z := Person{&quot;Zaphod Beeblebrox&quot;, 9001}
	fmt.Println(a, z)
}

// IPAddr type
type IPAddr [4]byte

func (ip IPAddr) String() string {
	return fmt.Sprintf(&quot;%v.%v.%v.%v&quot;, ip[0], ip[1], ip[2], ip[3])
}

func exerciseTest() {
	hosts := map[string]IPAddr{
		&quot;loopback&quot;:  {127, 0, 0, 1},
		&quot;googleDNS&quot;: {8, 8, 8, 8},
	}
	for name, ip := range hosts {
		fmt.Printf(&quot;%v: %v\n&quot;, name, ip)
	}
}

func main() {
	testStringers()
	exerciseTest()
}
</code></pre>
<ul>
<li><a href="https://github.com/zjs1224522500/GoLearn/blob/master/errors/errors.go">[5] Errors</a></li>
</ul>
<pre><code class="language-Go">package main

import &quot;fmt&quot;
func main() {
  fmt.Println(&quot;外层开始&quot;)
  defer func() {
    fmt.Println(&quot;外层准备recover&quot;)
    if err := recover(); err != nil {
      fmt.Printf(&quot;%#v-%#v\n&quot;, &quot;外层&quot;, err) // err已经在上一级的函数中捕获了，这里没有异常，只是例行先执行defer，然后执行后面的代码
    } else {
      fmt.Println(&quot;外层没做啥事&quot;)
    }
    fmt.Println(&quot;外层完成recover&quot;)
  }()
  fmt.Println(&quot;外层即将异常&quot;)
  f()
  fmt.Println(&quot;外层异常后&quot;)
  defer func() {
    fmt.Println(&quot;外层异常后defer&quot;)
  }()
}

func f() {
  fmt.Println(&quot;内层开始&quot;)
  defer func() {
    fmt.Println(&quot;内层recover前的defer&quot;)
  }()

  defer func() {
    fmt.Println(&quot;内层准备recover&quot;)
    if err := recover(); err != nil {
      fmt.Printf(&quot;%#v-%#v\n&quot;, &quot;内层&quot;, err) // 这里err就是panic传入的内容
    }

    fmt.Println(&quot;内层完成recover&quot;)
  }()

  defer func() {
    fmt.Println(&quot;内层异常前recover后的defer&quot;)
  }()

  panic(&quot;异常信息&quot;)

  defer func() {
    fmt.Println(&quot;内层异常后的defer&quot;)
  }()

  fmt.Println(&quot;内层异常后语句&quot;) //recover捕获的一级或者完全不捕获这里开始下面代码不会再执行
}

</code></pre>
<ul>
<li><a href="https://github.com/zjs1224522500/GoLearn/blob/master/readers/readers.go">[6] Readers</a></li>
</ul>
<pre><code class="language-Go">package main

import (
	&quot;fmt&quot;
	&quot;io&quot;
	&quot;os&quot;
	&quot;strings&quot;
)

func basicReaderTest() {
	r := strings.NewReader(&quot;Hello, Reader!&quot;)

	b := make([]byte, 8)
	for {
		n, err := r.Read(b)
		fmt.Printf(&quot;n = %v err = %v b = %v\n&quot;, n, err, b)
		fmt.Printf(&quot;b[:n] = %q\n&quot;, b[:n])
		if err == io.EOF {
			break
		}
	}
}

// Implement a Reader type that emits an infinite stream of the ASCII character 'A'.
// import &quot;golang.org/x/tour/reader&quot;
// MyReader struct
type MyReader struct{}

func (r MyReader) Read(b []byte) (int, error) {
	for i := 0; i &lt; len(b); i++ {
		b[i] = 'A'
	}
	return len(b), nil
}
func readerExercise() {
	// reader.Validate(MyReader{})
}

type rot13Reader struct {
	r io.Reader
}

func (rot *rot13Reader) Read(b []byte) (int, error) {
	n, e := rot.r.Read(b)

	for i := 0; i &lt; n; i++ {
		if (b[i] &gt;= 'A' &amp;&amp; b[i] &lt; 'N') || (b[i] &gt;= 'a' &amp;&amp; b[i] &lt; 'n') {
			b[i] += 13
		} else if (b[i] &gt; 'M' &amp;&amp; b[i] &lt;= 'Z') || (b[i] &gt; 'm' &amp;&amp; b[i] &lt;= 'z') {
			b[i] -= 13
		}
	}
	return n, e
}

func rot13ReaderTest() {
	// Build string reader
	s := strings.NewReader(&quot;Lbh penpxrq gur pbqr!&quot;)
	// Build rot13 reader
	r := rot13Reader{s}
	// Call reader.read
	io.Copy(os.Stdout, &amp;r)
}

func main() {
	basicReaderTest()
	rot13ReaderTest()
}
</code></pre>
<ul>
<li><a href="https://github.com/zjs1224522500/GoLearn/blob/master/images/images.go">[7] Images</a></li>
</ul>
<pre><code class="language-Go">package main

import (
	&quot;fmt&quot;
	&quot;image&quot;
	&quot;image/color&quot;
	//&quot;golang.org/x/tour/pic&quot;
)

// package image

// type Image interface {
//     ColorModel() color.Model
//     Bounds() Rectangle
//     At(x, y int) color.Color
// }

func testImage() {
	m := image.NewRGBA(image.Rect(0, 0, 100, 100))
	fmt.Println(m.Bounds())
	fmt.Println(m.At(0, 0).RGBA())
}

// Image Struct
type Image struct{ w, h int }

// ColorModel method
func (i Image) ColorModel() color.Model {
	return color.RGBAModel
}

// Bounds method
func (i Image) Bounds() image.Rectangle {
	return image.Rect(0, 0, i.w, i.h)
}

// At method
func (i Image) At(x, y int) color.Color {
	r, g, b := uint8(x*y), uint8(x^y), uint8((x+y)/2)
	return color.RGBA{r, g, b, 255}
}

func imageExercise() {
	// m := Image{1000, 1000}
	// pic.ShowImage(m)
}

func main() {
	testImage()
}
</code></pre>
<h4 id="concurrency">Concurrency</h4>
<ul>
<li><a href="https://github.com/zjs1224522500/GoLearn/blob/master/goroutines/goroutines.go">[1] Goroutines</a>
<ul>
<li>关于 Go 的并发相关可以单独再开一篇介绍了，此处不表。</li>
</ul>
</li>
</ul>
<pre><code class="language-Go">package main

import (
	&quot;fmt&quot;
	&quot;time&quot;
)

func say(s string) {
	for i := 0; i &lt; 5; i++ {
		time.Sleep(100 * time.Millisecond)
		fmt.Println(s)
	}
}

func goroutinesTest() {
	go say(&quot;world&quot;)
	say(&quot;hello&quot;)
}

func main() {
	goroutinesTest()
}
</code></pre>
<ul>
<li><a href="https://github.com/zjs1224522500/GoLearn/blob/master/channels/channels.go">[2] Channels</a>
<ul>
<li><a href="https://tour.golang.org/concurrency/8">Exercise Binary Tree Desc</a></li>
<li><a href="https://github.com/zjs1224522500/GoLearn/blob/master/binaryTrees/binaryTrees.go">Exercise Binary Tree Solution</a></li>
</ul>
</li>
</ul>
<pre><code class="language-Go">package main

import (
	&quot;fmt&quot;

	&quot;golang.org/x/tour/tree&quot;
)

// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
	if t != nil {
		Walk(t.Left, ch)
		ch &lt;- t.Value
		Walk(t.Right, ch)
	}
}

func goWalk(t *tree.Tree, ch chan int) {
	Walk(t, ch)
	close(ch)
}

// Same determines whether the trees
// t1 and t2 contain the same values.
func Same(t1, t2 *tree.Tree) bool {
	ch1, ch2 := make(chan int, 10), make(chan int, 10)
	go goWalk(t1, ch1)
	go goWalk(t2, ch2)
	for {
		v1, ok1 := &lt;-ch1
		v2, ok2 := &lt;-ch2
		if ok1 != ok2 || v1 != v2 {
			return false
		}

		if ok1 == false {
			break
		}
	}
	return true
}

func main() {
	ch := make(chan int)
	go Walk(tree.New(1), ch)
	fmt.Println(Same(tree.New(1), tree.New(2)))
	fmt.Println(Same(tree.New(1), tree.New(1)))
	fmt.Println(Same(tree.New(2), tree.New(1)))
}
</code></pre>
<ul>
<li><a href="https://github.com/zjs1224522500/GoLearn/blob/master/mutex/mutex.go">[3] Mutex</a>
<ul>
<li><a href="https://tour.golang.org/concurrency/10">Exercise Web Crawler Desc</a></li>
<li><a href="https://github.com/zjs1224522500/GoLearn/blob/master/webcrawler/web-crawler.go">Exercise Web Crawler Solution</a></li>
</ul>
</li>
</ul>
<pre><code class="language-Go">package main

import (
	&quot;fmt&quot;
	// No longer needed for sleeping.
	//&quot;time&quot;
	&quot;sync&quot;
)

type Fetcher interface {
	// Fetch returns the body of URL and
	// a slice of URLs found on that page.
	Fetch(url string) (body string, urls []string, err error)
}
type SafeCounter struct {
	v   map[string]bool
	mux sync.Mutex
	wg  sync.WaitGroup
}

var c SafeCounter = SafeCounter{v: make(map[string]bool)}

func (s SafeCounter) checkvisited(url string) bool {
	s.mux.Lock()
	defer s.mux.Unlock()
	_, ok := s.v[url]
	if ok == false {
		s.v[url] = true
		return false
	}
	return true

}

// Crawl uses fetcher to recursively crawl
// pages starting with url, to a maximum of depth.
func Crawl(url string, depth int, fetcher Fetcher) {
	// TODO: Fetch URLs in parallel.
	// TODO: Don't fetch the same URL twice.
	// This implementation doesn't do either:
	defer c.wg.Done()
	if depth &lt;= 0 {
		return
	}
	if c.checkvisited(url) {
		return
	}
	body, urls, err := fetcher.Fetch(url)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Printf(&quot;found: %s %q\n&quot;, url, body)
	for _, u := range urls {
		c.wg.Add(1)
		go Crawl(u, depth-1, fetcher)
	}
	return
}

func main() {
	c.wg.Add(1)
	Crawl(&quot;http://golang.org/&quot;, 4, fetcher)
	c.wg.Wait()
	// Not ideal to sleep on the main thread.
	//time.Sleep(5*time.Second)
}

// fakeFetcher is Fetcher that returns canned results.
type fakeFetcher map[string]*fakeResult

type fakeResult struct {
	body string
	urls []string
}

func (f fakeFetcher) Fetch(url string) (string, []string, error) {
	if res, ok := f[url]; ok {
		return res.body, res.urls, nil
	}
	return &quot;&quot;, nil, fmt.Errorf(&quot;not found: %s&quot;, url)
}

// fetcher is a populated fakeFetcher.
var fetcher = fakeFetcher{
	&quot;http://golang.org/&quot;: &amp;fakeResult{
		&quot;The Go Programming Language&quot;,
		[]string{
			&quot;http://golang.org/pkg/&quot;,
			&quot;http://golang.org/cmd/&quot;,
		},
	},
	&quot;http://golang.org/pkg/&quot;: &amp;fakeResult{
		&quot;Packages&quot;,
		[]string{
			&quot;http://golang.org/&quot;,
			&quot;http://golang.org/cmd/&quot;,
			&quot;http://golang.org/pkg/fmt/&quot;,
			&quot;http://golang.org/pkg/os/&quot;,
		},
	},
	&quot;http://golang.org/pkg/fmt/&quot;: &amp;fakeResult{
		&quot;Package fmt&quot;,
		[]string{
			&quot;http://golang.org/&quot;,
			&quot;http://golang.org/pkg/&quot;,
		},
	},
	&quot;http://golang.org/pkg/os/&quot;: &amp;fakeResult{
		&quot;Package os&quot;,
		[]string{
			&quot;http://golang.org/&quot;,
			&quot;http://golang.org/pkg/&quot;,
		},
	},
}
</code></pre>

                </div>
                <div class="clear"></div>
              </section>
            </article>
            <div class="clear"></div>

            <section class="related section">
              
              <article class="prev grid-50 tablet-grid-50 grid-parent">
                <div class="thumb cover lazy loaded" style="background-image: url('https://raw.githubusercontent.com/zjs1224522500/PicGoImages/master//img/blog/20200612084833.png');"></div>
                 <a href="https://blog.shunzi.tech/post/distributed-storage-system-basic/" class="full-link"></a>
                 <div class="info">
                  <time datetime="2020-06-12">2020-06-12</time>
                  <h4 class="title white no-margin">Distributed Storage System Basic</h4>
                </div>
                 <span class="epcl-button red">
                  <img src="https://blog.shunzi.tech/media/images/left-arrow.svg" width="15" alt="Left Arrow">
                </span>
                <div class="overlay"></div>
              </article>
              
              
              <article class="next grid-50 tablet-grid-50 grid-parent">
                <div class="thumb cover lazy loaded" style="background-image: url('https://raw.githubusercontent.com/zjs1224522500/PicGoImages/master//img/blog/20200522175313.png');"></div>
                 <a href="https://blog.shunzi.tech/post/s3fs/" class="full-link"></a>
                 <div class="info">
                  <time datetime="2020-05-22">2020-05-22</time>
                  <h4 class="title white no-margin">S3FS</h4>
                </div>
                 <span class="epcl-button red">
                  <img src="https://blog.shunzi.tech/media/images/right-arrow.svg" width="15" alt="Left Arrow">
                </span>
                <div class="overlay"></div>
              </article>
              

                <div class="clear"></div>
            </section>

              <div class="clear"></div>
              
            
              <div id="comments" class="bg-white hosted ">
                <div class="clear"></div>
<script>
jQuery(document).ready(function($){
    $('.vemoji-btn').text('😀');
    $("#comments").on('click', 'span.vat',function(){
        $(this).parent('div.vmeta').next("div.vcontent").after($("div.vwrap"));
        $('textarea#veditor').focus();
    })
    if(window.location.hash){
        var checkExist = setInterval(function() {
            if ($(window.location.hash).length) {
                $('html, body').animate({scrollTop: $(window.location.hash).offset().top-200}, 600);
                clearInterval(checkExist);
            }
        }, 100);
    }
})
</script>

              </div>
            

            </div>
          </div>
      </main>

          <footer id="footer" class="grid-container">
        <div class="widgets row gradient-effect">
            <div class="default-sidebar border-effect">
              <div class="grid-33 tablet-grid-50 mobile-grid-100">
                <section id="tag_cloud-2" class="widget widget_epcl_posts_thumbs underline-effect">
                  <h4 class="widget-title title white bordered">最新文章</h4>
                  
                  
                  <article class="item post-0 post type-post status-publish format-standard has-post-thumbnail hentry">
                    <a href="https://blog.shunzi.tech/post/cpp-multi-thread/" class="thumb hover-effect">
                      <span class="fullimage cover" style="display:block;border-radius:50%;background-image: url('https://raw.githubusercontent.com/zjs1224522500/PicGoImages/master//img/blog/20210513192958.png');"></span>
                    </a>
                    <div class="info gradient-effect">
                      <time datetime="2021-05-06">2021-05-06</time>
                      <h4 class="title usmall">
                        <a href="https://blog.shunzi.tech/post/cpp-multi-thread/">C++ 多线程</a>
                      </h4>
                    </div>
                    <div class="clear"></div>
                  </article>
                  
                  
                  
                  <article class="item post-1 post type-post status-publish format-standard has-post-thumbnail hentry">
                    <a href="https://blog.shunzi.tech/post/c-basic/" class="thumb hover-effect">
                      <span class="fullimage cover" style="display:block;border-radius:50%;background-image: url('https://raw.githubusercontent.com/zjs1224522500/PicGoImages/master//img/blog/20210513192631.png');"></span>
                    </a>
                    <div class="info gradient-effect">
                      <time datetime="2021-04-06">2021-04-06</time>
                      <h4 class="title usmall">
                        <a href="https://blog.shunzi.tech/post/c-basic/">C 基础</a>
                      </h4>
                    </div>
                    <div class="clear"></div>
                  </article>
                  
                  
                  
                  <article class="item post-2 post type-post status-publish format-standard has-post-thumbnail hentry">
                    <a href="https://blog.shunzi.tech/post/basic-of-concurrency-one/" class="thumb hover-effect">
                      <span class="fullimage cover" style="display:block;border-radius:50%;background-image: url('https://raw.githubusercontent.com/zjs1224522500/PicGoImages/master//img/blog/20200717213648.png');"></span>
                    </a>
                    <div class="info gradient-effect">
                      <time datetime="2021-04-05">2021-04-05</time>
                      <h4 class="title usmall">
                        <a href="https://blog.shunzi.tech/post/basic-of-concurrency-one/">Series Three of Basic of Concurrency - Condition Variables</a>
                      </h4>
                    </div>
                    <div class="clear"></div>
                  </article>
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  <div class="clear"></div>
                </section>
              </div>

              <div class="grid-33 tablet-grid-50 mobile-grid-100">
                <section id="tag_cloud-2" class="widget widget_tag_cloud underline-effect">
                  <h4 class="widget-title title white bordered">标签云</h4>
                  <div class="tagcloud">
                    
                      <a href="https://blog.shunzi.tech/tag/n2w6bz87h/" class="ctag ctag-0 ctag-n2w6bz87h" aria-label="">编程语言</a>
                    
                      <a href="https://blog.shunzi.tech/tag/3zCwFWPHxH/" class="ctag ctag-1 ctag-3zCwFWPHxH" aria-label="">存储</a>
                    
                      <a href="https://blog.shunzi.tech/tag/la-n8a0mo/" class="ctag ctag-2 ctag-la-n8a0mo" aria-label="">读书笔记</a>
                    
                      <a href="https://blog.shunzi.tech/tag/os/" class="ctag ctag-3 ctag-os" aria-label="">OS</a>
                    
                      <a href="https://blog.shunzi.tech/tag/5uQUdLlSC/" class="ctag ctag-4 ctag-5uQUdLlSC" aria-label="">Paper</a>
                    
                      <a href="https://blog.shunzi.tech/tag/_jfuTNqah/" class="ctag ctag-5 ctag-_jfuTNqah" aria-label="">LSM</a>
                    
                      <a href="https://blog.shunzi.tech/tag/hbaTDSglx-/" class="ctag ctag-6 ctag-hbaTDSglx-" aria-label="">工具</a>
                    
                      <a href="https://blog.shunzi.tech/tag/EO3XpMf_y/" class="ctag ctag-7 ctag-EO3XpMf_y" aria-label="">Linux</a>
                    
                      <a href="https://blog.shunzi.tech/tag/wAFV_pvXZ/" class="ctag ctag-8 ctag-wAFV_pvXZ" aria-label="">cs-course</a>
                    
                      <a href="https://blog.shunzi.tech/tag/VqiGqmxbod/" class="ctag ctag-9 ctag-VqiGqmxbod" aria-label="">6.824</a>
                    
                      <a href="https://blog.shunzi.tech/tag/geK0jEW-T/" class="ctag ctag-10 ctag-geK0jEW-T" aria-label="">分布式</a>
                    
                      <a href="https://blog.shunzi.tech/tag/l8sKsLUAi/" class="ctag ctag-11 ctag-l8sKsLUAi" aria-label="">KVS</a>
                    
                      <a href="https://blog.shunzi.tech/tag/9msH-lUaA/" class="ctag ctag-12 ctag-9msH-lUaA" aria-label="">缓存</a>
                    
                      <a href="https://blog.shunzi.tech/tag/i2b42Y2j6/" class="ctag ctag-13 ctag-i2b42Y2j6" aria-label="">Ceph</a>
                    
                      <a href="https://blog.shunzi.tech/tag/oBVOD8v4ou/" class="ctag ctag-14 ctag-oBVOD8v4ou" aria-label="">一致性</a>
                    
                      <a href="https://blog.shunzi.tech/tag/gqgftpk_y/" class="ctag ctag-15 ctag-gqgftpk_y" aria-label="">AI</a>
                    
                      <a href="https://blog.shunzi.tech/tag/shu-ju-ku/" class="ctag ctag-16 ctag-shu-ju-ku" aria-label="">数据库</a>
                    
                      <a href="https://blog.shunzi.tech/tag/ZnIN9Ge-w/" class="ctag ctag-17 ctag-ZnIN9Ge-w" aria-label="">对象存储</a>
                    
                      <a href="https://blog.shunzi.tech/tag/4zx4ysLGro/" class="ctag ctag-18 ctag-4zx4ysLGro" aria-label="">云计算</a>
                    
                      <a href="https://blog.shunzi.tech/tag/Y_nsOD1At/" class="ctag ctag-19 ctag-Y_nsOD1At" aria-label="">SSD</a>
                    
                      <a href="https://blog.shunzi.tech/tag/E2d1yYZcV8/" class="ctag ctag-20 ctag-E2d1yYZcV8" aria-label="">虚拟化</a>
                    
                      <a href="https://blog.shunzi.tech/tag/PhD/" class="ctag ctag-21 ctag-PhD" aria-label="">Ph.D</a>
                    
                      <a href="https://blog.shunzi.tech/tag/ZqEqvRTvl/" class="ctag ctag-22 ctag-ZqEqvRTvl" aria-label="">网络</a>
                    
                      <a href="https://blog.shunzi.tech/tag/PuY19cs53/" class="ctag ctag-23 ctag-PuY19cs53" aria-label="">仿真</a>
                    
                      <a href="https://blog.shunzi.tech/tag/rIIc9E-ZvN/" class="ctag ctag-24 ctag-rIIc9E-ZvN" aria-label="">系统结构</a>
                    
                      <a href="https://blog.shunzi.tech/tag/fu-wu-qi/" class="ctag ctag-25 ctag-fu-wu-qi" aria-label="">服务器</a>
                    
                      <a href="https://blog.shunzi.tech/tag/X-lnqf1Ex/" class="ctag ctag-26 ctag-X-lnqf1Ex" aria-label="">容器</a>
                    
                      <a href="https://blog.shunzi.tech/tag/5h7k39FKw/" class="ctag ctag-27 ctag-5h7k39FKw" aria-label="">C语言</a>
                    
                      <a href="https://blog.shunzi.tech/tag/diary/" class="ctag ctag-28 ctag-diary" aria-label="">Diary</a>
                    
                      <a href="https://blog.shunzi.tech/tag/DyzFtOe6x/" class="ctag ctag-29 ctag-DyzFtOe6x" aria-label="">计算机基础</a>
                    
                      <a href="https://blog.shunzi.tech/tag/oqE3oKihb/" class="ctag ctag-30 ctag-oqE3oKihb" aria-label="">OpenStack</a>
                    
                      <a href="https://blog.shunzi.tech/tag/p_z7gKe6R/" class="ctag ctag-31 ctag-p_z7gKe6R" aria-label="">中间件</a>
                    
                      <a href="https://blog.shunzi.tech/tag/Test/" class="ctag ctag-32 ctag-Test" aria-label="">测试</a>
                    
                      <a href="https://blog.shunzi.tech/tag/Product-Standard/" class="ctag ctag-33 ctag-Product-Standard" aria-label="">Product Standard</a>
                    
                      <a href="https://blog.shunzi.tech/tag/spring/" class="ctag ctag-34 ctag-spring" aria-label="">Spring</a>
                    
                      <a href="https://blog.shunzi.tech/tag/she-ji-mo-shi/" class="ctag ctag-35 ctag-she-ji-mo-shi" aria-label="">设计模式</a>
                    
                      <a href="https://blog.shunzi.tech/tag/mian-jing/" class="ctag ctag-36 ctag-mian-jing" aria-label="">面经</a>
                    
                      <a href="https://blog.shunzi.tech/tag/suan-fa/" class="ctag ctag-37 ctag-suan-fa" aria-label="">算法</a>
                    
                      <a href="https://blog.shunzi.tech/tag/redis/" class="ctag ctag-38 ctag-redis" aria-label="">Redis</a>
                    
                      <a href="https://blog.shunzi.tech/tag/javaweb/" class="ctag ctag-39 ctag-javaweb" aria-label="">JavaWeb</a>
                    
                      <a href="https://blog.shunzi.tech/tag/KyMCZj2Wl/" class="ctag ctag-40 ctag-KyMCZj2Wl" aria-label="">WEB容器</a>
                    
                      <a href="https://blog.shunzi.tech/tag/javase/" class="ctag ctag-41 ctag-javase" aria-label="">JavaSE</a>
                    
                  </div>
                  <div class="clear"></div>
                </section>
              </div>

              <div class="grid-33 tablet-grid-50 mobile-grid-100">
                <section id="epcl_about-2" class="widget widget_epcl_about underline-effect">
                  <h4 class="widget-title title white bordered">关于我</h4>
                  <div class="avatar">
                    <a href="" class="translate-effect thumb"><span class="fullimage cover" style="background-image: url(https://blog.shunzi.tech/images/avatar.png);"></span></a>
                  </div>
                  <div class="info">
                    <h4 class="title small author-name gradient-effect no-margin"><a href="">Elvis Zhang</a></h4>
                    <p class="founder">The easy way or the right way.</p>
                    <div class="social">
                      
                          
                            <a href="https://github.com/zjs1224522500" class="translate-effect" target="_blank"><i class="fa fa-github"></i></a>
                        
                      
                          
                            <a href="https://twitter.com/1224522500Elvis" class="translate-effect" target="_blank"><i class="fa fa-twitter"></i></a>
                        
                      
                        
                      
                        
                      
                        
                      
                    </div> 
                  </div>
                  <div class="clear"></div>
                  </section>
              </div>

            </div>
            <div class="clear"></div>
        </div>

        <div class="logo">
          <a href="https://blog.shunzi.tech"><img src="\media\images\custom-footerLogo.jpg" alt=""></a>
        </div>
        <p class="published border-effect">
          ©2019 共 115 篇文章
          <br/>
          Theme <a href="https://gridea.dev/" target="_blank">「breek」</a> Powered by <a href="https://gridea.dev/" target="_blank">「Gridea」</a>
        </p>
        
        <a href="javascript:void(0)" id="back-to-top" class="epcl-button dark" style="display:none">
          <i class="fa fa-arrow"></i>
        </a>
    </footer>
    
    <div class="clear"></div>

        
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/leancloud-storage/dist/av-min.js"></script>
<script type="text/javascript" src="https://cdn.staticfile.org/valine/1.3.10/Valine.Pure.min.js"></script>
<script>
    new Valine({
        el: '#comments',
        appId: 'Pj5H1z0w7hJlLGJpGBh9NrCq-MdYXbMMI' ,
        appKey: 'LdR8vK5EaBfK87esF7tlbsXe',
        pageSize: 30,
        placeholder: '既然来了，那就留个痕迹吧~',
        visitor: true // 阅读量统计
    })
</script>
    

      
    <script src="https://blog.shunzi.tech/media/js/functions-post.js"></script>

    </div>
    <!-- end: #wrapper -->
  </body>
</html>
